package org.example.myleet.rosalind.subs;

import java.util.ArrayList;
import java.util.List;

public class Solution {
    public List<Integer> findMotifs(String dna, String motif) {
        List<Integer> result = new ArrayList<>();
        int i = dna.indexOf(motif);
        while (i > -1) {
            result.add(++i);
            i = dna.indexOf(motif, i);
        }
        return result;
    }

    public static void main(String[] args) {
        Solution solution = new Solution();
        print(solution.findMotifs("GATATATGCATATACTT", "ATAT"));
        print(solution.findMotifs("CCGCAGGGTAATACCGCAGGGAGCCCGCAGGATCCGCAGGTCATCCCGCAGGCCGCAGGTCCGCAGGAGCTTATGCCGCAGGGCTCTATCCCGCAGGTTCCGCAGGCCCGCAGGATTACCGCAGGCTATAACCCGCAGGGCAGCCGCAGGTGATCCTCAGCCAGCCCCGCAGGCGAACAGGACCCGCAGGCCGCAGGCCGCAGGCCGCAGGGCCGCAGGCCGCAGGCGCGCCGCAGGCCGCAGGGCCGCAGGTCCCGCAGGCCGCAGGGCCGCAGGCCCGCAGGGGATTAACCGCAGGGCCGCAGGGACCCTTCACGCCGCAGGTCCGCAGGAAACCGCAGGGCCGCAGGCACTAGTCCGCAGGCCGCAGGATCCGCAGGGAGTACACCGCAGGTGTTTCCGCAGGCGCCGCAGGCTTCACCGCAGGTCGACTCGCCGCAGGCCGCAGGGCCCGCAGGCCGCAGGGTACGGACTGATAACCGCAGGCCGCAGGCCGTCCGCAGGCCGCAGGACCGCAGGCCGCAGGCTCCGCAGGAATCAGCCGCAGGCATCCCGCAGGCCGCAGGATGCCGCAGGTTACCGCAGGCATCCGCAGGGCCGCAGGACCGCAGGCCGCAGGACCGCAGGACCGCAGGCCGCCGCAGGCCGCAGGACCGCAGGCCGCAGGCCGCAGGGTACCCCCGCAGGCTCCGCCCGCAGGCCGCAGGTCACACAACCGCAGGCCCACCTACCGCAGGTTTTGCGCGCGGCCGCAGGGATCCCGCAGGTGACGCCGCAGGAACCGCAGGCGCCGCCGCAGGGTCCGCAGGCCGCAGGCCGCAGGTTTAGTCCGCAGGCCGCAGGCCACCGCAGGGCCGCAGGCCGCAGGTTCCGCAGGCGCAATCCGCAGGTCCATTCCGCAGGGGCTTTCCGCAGGCCATAAGTATCCGCAGGTCACCGCAGGGGTCCGCAGGGTGCCGCAGGCCGCAGGTATCCCGCAGGACCGCAGGGCCC", "CCGCAGGCC"));
    }
    private static void print(List<Integer> result) {
        for (int i : result) {
            System.out.print(i + " ");
        }
        System.out.println();
    }
}
